Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check decorated connection responds to open_transactions before invoking #341

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lewispb
Copy link

@lewispb lewispb commented Jan 11, 2022

An ActiveRecord::Base.connection responds to open_transactions but other connections such as a Redis client do not.

Continues from and closes #324, I've also added the specs as discussed there.

As per @rosa's original PR:

We have an instance of a Makara proxy we use for Redis, for read-write splitting. It looks like this:

class RedisProxy < Makara::Proxy

  # ...

  def connection_for(config)
    Redis.new(config)
  end

  # ...
end

The connection returned is an instance of a Redis client, which doesn't respond to open_transactions, so after updating to v0.5.1, any errors on Redis that would result in a Makara::Errors::BlacklistConnection, now result in a Redis::CommandError: ERR unknown command 'open_transactions'.

An `ActiveRecord::Base.connection` responds to this but other
connections such as a Redis client do not.
Copy link
Contributor

@rosa rosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌 Thank you @lewispb!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants